home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / fflip217.zip / FFCTL.C < prev    next >
C/C++ Source or Header  |  1992-02-09  |  5KB  |  129 lines

  1. //
  2. //---------------------------------------------------------------------------
  3. //---------------------------------------------------------------------------
  4. // $Workfile:   ffctl.c  $
  5. // $Revision:   1.0  $
  6. //   $Author:   Doc  $
  7. //  $Modtime:   09 Feb 1992 07:23:20  $
  8. //      $Log:   D:/CR/ADK/VCS/FFCTL.C_V  $
  9. // 
  10. //    Rev 1.0   09 Feb 1992 07:24:02   Doc
  11. // Initial revision.
  12. //---------------------------------------------------------------------------
  13. //---------------------------------------------------------------------------
  14. //
  15. //  Simple control utility for FastFlip v2.15
  16. //  Compiled with Borland C++ v2.0
  17. //  Should compile with TurboC (any version) and that "other" compiler
  18. //
  19. //  This util uses the multiplex interface to communicate with FastFlip.
  20. //  See "Microsoft Encyclopedia" (or another DOS reference) for a detailed
  21. //  discussion of the multiplex interrupt.
  22. //
  23. //  FastFlip uses an mpx id of hex 92.
  24. //
  25. //  -----------------------------------------------------------------------
  26. //
  27.  
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include <dos.h>
  31. #include <ff.h>
  32.  
  33. #define   byte  unsigned char
  34. #define   word  unsigned int
  35.  
  36.  
  37. int  DoArgs(char *argv[],                    //command line
  38.             char Sw,                         //switch char
  39.             char *ArgStrs[],                 //static arg triggers
  40.             void(*call)(char *s,int f));     //function to call on trigger
  41.  
  42. //
  43. //------------------------------------------------------------------------
  44. //
  45. //------------------------------------------------------------------------
  46. //
  47. void DoUsage(void)
  48. {
  49.   puts("\a\n"
  50.        "USAGE: FFCTL <option>\n\n"
  51.        "       -L    Lock\n"
  52.        "       -U    Unlock\n"
  53.        "       -P#   Goto page #\n"
  54.        "       -T#   Set timer to # clicks\n");
  55.   exit (9);
  56. }
  57.  
  58.  
  59. //----------------------------------------------------------------------------
  60. //----------------------------------------------------------------------------
  61. //----------------------------------------------------------------------------
  62. void _ArgProc(char *s, int FlagChr)
  63. {
  64.   int   i;
  65.   int   page;
  66.   int   maxpages;
  67.  
  68.   if (FlagChr < 256)
  69.     FlagChr = toupper(FlagChr);
  70.  
  71.   switch(FlagChr)                                   //
  72.   {                                                 //
  73.     case 'L':                                       //lock
  74.       ffSetLock(1);                                 //
  75.       puts("FastFlip locked");                      //
  76.       break;                                        //
  77.     case 'U':                                       //unlock
  78.       ffSetLock(0);                                 //
  79.       puts("FastFlip unlocked");                    //
  80.       break;                                        //
  81.     case 'P':                                       //set page
  82.       page = atoi(s);                               //
  83.       if (!page)                                    //
  84.       { puts("\aError: Invalid page number\n\n");   //
  85.         DoUsage();                                  //
  86.       }                                             //
  87.       //                                            //
  88.       // make sure requested page is defined        //
  89.       //                                            //
  90.       maxpages = ffGetMaxPage();                    //
  91.       if (page > maxpages)                          //
  92.       { puts("\aError: Invalid page number\n\n");   //
  93.         DoUsage();                                  //
  94.       }                                             //
  95.       ffSetPage(--page);                            //make 0 based
  96.       break;                                        //
  97.     case 'T':                                       //set timer
  98.       i = atoi(s);                                  //
  99.       if (i)                                        //
  100.         ffSetTimer(i);                              //
  101.       break;                                        //
  102.   }
  103. }
  104.  
  105. //
  106. //------------------------------------------------------------------------
  107. // main
  108. //------------------------------------------------------------------------
  109. //
  110. int  main(int argc, char *argv[])
  111. {
  112.   puts("\nFastFlip Control Program");
  113.   puts("Copyright (c) 1992 Chris Curran");
  114.   puts("---------------------------------------------------------------");
  115.  
  116.   //
  117.   // is fastflip loaded?
  118.   //
  119.   if (!ffLoaded())
  120.   { puts("\n\aFastFlip is not loaded\n");
  121.     exit(1);
  122.   }
  123.  
  124.   argc = DoArgs(argv,'-',NULL,_ArgProc);
  125.   if (!argc)
  126.     DoUsage();
  127.   return 0;
  128. }
  129.